/**************************************************************************/
/* FILE NAME: FLASH_OPS.h                                                  */
/*                                                                        */
/* DESCRIPTION:                                                           */
/* This file contains prototypes and definitions for Initializing OPENECU */
/*                                                                        */
/*========================================================================*/
/*ORIGINAL AUTHOR:  Paul Schlein                                          */
/* REV    AUTHOR        DATE          DESCRIPTION OF CHANGE               */
/* ---    -----------   -----------   ---------------------               */
/* 1.0    P. Schlein    31/Oct/11     Initial version.                    */
/**************************************************************************/

#include "cpu.h"

/**************************************************************************/
/*                            Definitions                                 */
/**************************************************************************/
#define BLOCK0 0
#define BLOCK1 1

#ifdef MPC5554
#define M0_BASE (uint32_t *)0x00040000
#define H0_BASE (uint32_t *)0x00080000
#endif

#ifdef MPC5634
#define M0_BASE (uint32_t *)0x00080000
#define H0_BASE (uint32_t *)0x00100000
#endif


/**************************************************************************/

/**************************************************************************/
/*                       Function Prototypes                              */
/**************************************************************************/

/**************************************************************************/
/*                       C Code Prototypes                                */
/**************************************************************************/


/*This function Initializes, Erases and Programs the MPC5xxx FLASH Memory */

void init_FLASH(void);

void Erase_H0(void);
void Erase_M0(void);

void *Program_M0(uint32_t *source, uint32_t destination);
void *Program_H0(uint32_t *source, uint32_t destination);

void *Flash_Program(uint_fast8_t block, uint32_t *source, uint32_t destination);
void Flash_Erase(uint_fast8_t block);
int32_t Flash_Ready(void);
void Flash_Finish(void);
